﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace V5_EaspLibs.Helper {

    /// <summary>
    /// 字符输入出操作
    /// </summary>
    public class InputHelper {
        /// <summary>
        /// 根据内容获取关键词列表
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string GetTagsList(string str) {
            string strTemp = string.Empty;
            string TxtContent = Easp.Fso.GetFileContent("App_Data\\zwck.txt");
            string[] CharCount = TxtContent.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in CharCount) {
                if (str.IndexOf(s) > -1) {
                    strTemp += s + ",";
                }
            }

            if (!string.IsNullOrEmpty(strTemp)) {
                strTemp = strTemp.Remove(strTemp.Length - 1);
            }

            return strTemp;
        }
        /// <summary>
        /// 内容伪原创
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string GetTongYiList(string str) {
            string TxtContent = Easp.Fso.GetFileContent("App_Data\\tongyi.txt");
            string[] CharCount = TxtContent.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            Dictionary<string, string> dic = new Dictionary<string, string>();
            foreach (string s in CharCount) {
                string[] sList = s.Split(new string[] { "," }, StringSplitOptions.None);
                dic.Add(sList[0], sList[1]);
            }
            foreach (KeyValuePair<string, string> item in dic) {
                str = str.Replace(item.Key, item.Value);
            }
            return str;
        }
    }
}
